<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
    <#include "../include.ftl">
    <meta charset="UTF-8">
    <title>首页</title>
    <style>
        .time {
            font-size: 13px;
            color: #999;
        }

        .bottom {
            margin-top: 13px;
            line-height: 12px;
        }

        .button {
            padding: 0;
            float: right;
        }

        .image {
            width: 100%;
            display: block;
        }

        .clearfix:before,
        .clearfix:after {
            display: table;
            content: "";
        }

        .clearfix:after {
            clear: both
        }
    </style>
</head>
<body>
<div id="app">
    <el-row>
        <el-col :span="8" v-for="(o, index) in count" :key="o" :offset="2">
            <el-card :body-style="{ padding: '0px' }">
                <img src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png"
                     class="image">
                <div style="padding: 14px;">
                    <span>Hamburg {{index+1}}</span>
                    <div class="bottom clearfix">
                        <time class="time">{{ currentDate }}</time>
                        <el-button type="text" class="button" @click="dialogFormVisible = true">buy</el-button>
                    </div>
                </div>
            </el-card>
        </el-col>
    </el-row>

    <!-- 打开支付方式 -->
    <el-dialog title="Pay Type" :visible.sync="dialogFormVisible">
        <el-form :model="form">
            <el-radio-group v-model="form.payType">
                <el-radio label="Alipay"></el-radio>
                <el-radio label="WeChat"></el-radio>
            </el-radio-group>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">cancel</el-button>
            <el-button type="primary" @click="pay">confirm</el-button>
        </div>
    </el-dialog>
</div>
</body>
<script type="text/javascript">
    new Vue({
        el: '#app',
        data: {
            count: 2,
            currentDate: new Date(),
            dialogFormVisible: false,
            form: {
                payType: "WeChat"
            },
        },
        methods: {
            pay() {
                this.dialogFormVisible = false; // 关闭弹窗
                // wechat 请求后台 请求出二维码
                if(this.form.payType == "WeChat"){
                    $.post(ctx + "/order/wx", {payType: this.form.payType}, function (res) {
                        console.log(res);
                        if( res.code === "SUCCESS"){
                            window.open(ctx+"/login/pay?url="+res.code_ulr+"", '_blank');
                        }
                    })
                }

            }
        }

    })
</script>
</html>
